<template>
  <!-- calc() 能计算的计算表达式里，计算符号两边要有空格
  default-active 高亮
  default-opends 默认展开-->
  <el-menu
      style="width: 200px; min-height: calc(100vh - 50px)"
      :default-active="path"
      router
  >

      <el-menu-item index="/admin">
        <i class="el-icon-user-solid"></i>
        <span>管理员查看</span>
      </el-menu-item>

      <el-menu-item index="/student" v-if="user.role === 1">
        <i class="el-icon-user"></i>
        <span>学生管理</span>
      </el-menu-item>

    <el-menu-item index="/advice">
      <i class="el-icon-data-board"></i>
      <span>公告管理</span>
    </el-menu-item>

    <el-menu-item index="/badgoods">
      <i class="el-icon-s-tools"></i>
      <span>维修管理</span>
    </el-menu-item>

    <el-menu-item index="/card">
      <i class="el-icon-sunny"></i>
      <span>打卡查看</span>
    </el-menu-item>

    <el-menu-item index="/violation">
      <i class="el-icon-circle-close"></i>
      <span>违纪管理</span>
    </el-menu-item>

    <el-menu-item index="/leave">
      <i class="el-icon-school"></i>
      <span>离校查看</span>
    </el-menu-item>


    <el-menu-item index="/person">
      <i class="el-icon-s-custom"></i>
      <span>个人信息</span>
    </el-menu-item>




  </el-menu>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      user: {},
      path: this.$route.path   // 设置默认高亮的菜单为当前路由
    }
  },
  created() {
    this.refreshUser()
  },
  methods: {
    refreshUser() {
      let userJson = sessionStorage.getItem("user");
      this.user = JSON.parse(userJson);
    },
  }
}
</script>

<style scoped>

</style>